<?php

use think\migration\Migrator;
use think\migration\db\Column;

class SystemConfig extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {
        $table = $this->table('system_config',['engine'=>'InnoDb']);
        $table->addColumn(Column::string('group')->setDefault('')->setComment('配置分组')->setLimit(25))
            ->addColumn(Column::string('key')->setDefault('')->setComment('配置标识')->setLimit(25))//标识
            ->addColumn(Column::string('title')->setDefault('')->setComment('标题')->setLimit(25))//
            ->addColumn(Column::string('type')->setDefault('')->setComment('配置类型')->setLimit(25))//
            ->addColumn(Column::string('value')->setDefault('')->setComment('配置内容')->setLimit(255))
            ->addColumn(Column::string('option')->setDefault('')->setComment('配置默认内容')->setLimit(255))
            ->addColumn(Column::string('tips')->setDefault('')->setComment('提示')->setLimit(150))
            ->addColumn(Column::integer('sort')->setDefault(0)->setComment('排序')->setLimit(11))
            ->addColumn(Column::integer('status')->setDefault(1)->setComment('状态')->setLimit(1))
            ->addColumn(Column::integer('updatetime')->setDefault(0)->setComment('修改时间')->setLimit(10))
            ->addColumn(Column::integer('createtime')->setDefault(0)->setComment('修改时间')->setLimit(10))
            ->addIndex(['group','key','title','value','status','type'])
            ->create();
    }
}
